Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle error if security scopes is invalid #2113

Merged

Conversation

AlexVarchuk
Copy link
Collaborator

What/Why/How?

fixes #2102

openapi: 3.0.3
info:
  title: book API
  version: 1.0.0
paths:
  "/book/{bid}":
    get:
      description: new description
      operationId: get_book_book__int_bid__get
      parameters:
      - description: book id
        in: path
        name: bid
        required: true
        schema:
          description: book id
          title: Bid
          type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/BookResponse"
            text/csv:
              schema:
                type: string
          description: OK
      security:
      - jwt: []
      - oauth2:
        - write:pets
        - read:pets
      - basic1:
          scheme: basic
          type: http
      summary: new summary
      tags:
      - book
tags:
- description: Some Book
  name: book
components:
  schemas:
    BookBodyWithID:
      properties:
        age:
          description: Age
          maximum: 4
          minimum: 2
          title: Age
          type: integer
        author:
          description: Author
          maxLength: 4
          minLength: 2
          title: Author
          type: string
        bid:
          description: book id
          title: Bid
          type: integer
      required:
      - bid
      title: BookBodyWithID
      type: object
    BookResponse:
      properties:
        code:
          default: 0
          description: Status Code
          title: Code
          type: integer
        data:
          "$ref": "#/components/schemas/BookBodyWithID"
        message:
          default: ok
          description: Exception Information
          title: Message
          type: string
      title: BookResponse
      type: object
  securitySchemes:
    api_key:
      in: header
      name: api key
      type: apiKey
    basic1:
      scheme: basic
      type: http
    jwt:
      bearerFormat: JWT
      scheme: bearer
      type: http
    oauth2:
      flows:
        implicit:
          authorizationUrl: https://example.com/api/oauth/dialog
          scopes:
            read:pets: read your pets
            write:pets: modify pets in your account
      type: oauth2

Reference

Testing

Screenshots (optional)

AFTER
Screenshot 2022-08-01 at 20 20 13
BEFORE
Screenshot 2022-08-01 at 20 20 31

Check yourself

  • Code is linted
  • Tested
  • All new/updated code is covered with tests

@AlexVarchuk AlexVarchuk requested a review from a team as a code owner August 1, 2022 17:22
@AlexVarchuk AlexVarchuk self-assigned this Aug 1, 2022
@AlexVarchuk AlexVarchuk requested review from anastasiia-developer and removed request for a team August 1, 2022 17:22
@AlexVarchuk AlexVarchuk merged commit 428fd69 into master Aug 2, 2022
@AlexVarchuk AlexVarchuk deleted the fix/handle-crash-error-for-wrong-security-scopes branch August 2, 2022 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

e.scopes.map is not a function
2 participants